package com.scau.orderservice.controller;

import com.alibaba.fastjson.JSONObject;
import model.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
    @Autowired
    StringRedisTemplate redisTemplate;
    @GetMapping("test/redis")
    public String testRedis(){
        Test su = new Test(1, "su");
        redisTemplate.opsForValue().set("test"+su.getId(), JSONObject.toJSONString(su));
        Test test1 = JSONObject.parseObject(redisTemplate.opsForValue().get("test1"), Test.class);
        return test1.toString();

    }
}
